require 'pp'
require "digest/sha2"

class LoginController < ApplicationController
  def login
	if request.post?
          worker = Worker.authenticate params[:email], params[:password]

 	  if worker
	    session[:worker_id] = worker.id
            redirect_to(:controller => :events, :action => "index")
          else
            flash.now[:notice] = "Falsche E-Mail Addresse oder Password."
          end
        else
          @worker = Worker.new
        end
  end
  def logout
    session[:worker_id] = nil
    redirect_to "/login"
  end
end
